package com.fang.unittest;

import java.io.*;

public class TestDriver {
    public static void main(String[] args) {
        test04();
    }
    private static void test04(){
        try (
                BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
                ){
            System.out.println("请输入一段话,输入esc结束");
            String str= br.readLine();
            while(!str.trim().equalsIgnoreCase("esc")){
                System.out.println("您输入的内容为："+str);
                System.out.println("请输入一段话,输入esc结束");
                str= br.readLine();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    private static void test03() {
        try {
            //使用数据输出流对文件进行操作
            DataOutputStream dos=new DataOutputStream(new FileOutputStream("D:\\java\\lib\\xxx.txt"));
            //将内容写到文件中
            dos.writeUTF("春天的花都开了");
            dos.writeInt(1);
            //使用数据输入流读去输出流写入的内容
            DataInputStream dis=new DataInputStream(new FileInputStream("D:\\java\\lib\\xxx.txt"));
            //读取内容
            String st=dis.readUTF();
            int  in=dis.readInt();
            System.out.println(st);
            System.out.println(in);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
    private static void test02(){
        try (
                ObjectInputStream ois = new ObjectInputStream(new FileInputStream("D:\\java\\lib\\student.txt"));
                ){

            Object ob = ois.readObject();
            System.out.println(ob);

        } catch (IOException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
    private static void test01(){
        Student stu = new Student("李四",16,true);
        try (
                ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("D:\\java\\lib\\student.txt"));
                ){

            oos.writeObject(stu);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
